﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace KetBanBonPhuong
{
    /// <summary>
    /// Summary description for Engrypt
    /// </summary>
    public class Encrypt
    {
        public Encrypt()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public static String MD5Encrypt(String StrMessage)
        {
            if (String.IsNullOrEmpty(StrMessage))
            {
                return null;
            }

            System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(StrMessage);
            bs = x.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (byte b in bs)
            {
                s.Append(b.ToString("x2").ToLower());
            }
            return s.ToString().ToUpper();
        }
    }
}
